// import scriptUrl from '@/public/icons/iconfont.js';
import { createFromIconfontCN } from '@ant-design/icons-vue';
// 定義iconfont庫
const iconfontVersion = ['3905024_9iztsxx090q'];
const iconfontUrlCss = '//at.alicdn.com/t/c/font_$key.css';
const iconfontUrljs = '//at.alicdn.com/t/c/font_$key.js';

// 定義動態插入方法
const loadStyle = (url: string) => {
    const link = document.createElement('link');
    link.type = 'text/css';
    link.rel = 'stylesheet';
    link.href = url;
    const head = document.getElementsByTagName('head')[0];
    head.appendChild(link);
};
const MyIcon = createFromIconfontCN({
    // scriptUrl: scriptUrl, // 在 iconfont.cn 上生成
    scriptUrl: iconfontUrljs.replace('$key', iconfontVersion[0]), // 在 iconfont.cn 上生成
});
// 動態插入
iconfontVersion.forEach(ele => {
    loadStyle(iconfontUrlCss.replace('$key', ele));
});
const commonComponent = {
    install(Vue: any) {
        Vue.component('MyIcon', MyIcon);
    },
};
export default commonComponent;
